from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService, Service
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.microsoft import EdgeChromiumDriverManager

# 创建驱动对象
# 1 打开浏览器
# 1.1 方法一
ChromeIns = EdgeChromiumDriverManager().install()
driver = webdriver.Edge(ChromeIns)
# # 1.2 方法二
# driver = webdriver.Edge(EdgeChromiumDriverManager().install())

# 2 输入百度网址:https://www.baidu.com
driver.get("https://www.baidu.com")

# 3 找到输入框并输入“天行九歌”
driver.find_element(By.CSS_SELECTOR, "#kw").send_keys("天行九歌")

# 4 找到“百度一下”按钮并点击
driver.find_element(By.CSS_SELECTOR, "#su").click()

# 5 关闭浏览器
driver.quit()